function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var t = e(require("./util")), r = e(require("../../utils/config")), s = {
    userInfo: {
        desc: "用户信息",
        text: "微信昵称、头像等公开信息"
    },
    userLocation: {
        desc: "地理位置",
        text: "地理位置权限"
    },
    address: {
        desc: "通讯地址",
        text: "通讯地址权限"
    },
    record: {
        desc: "录音功能",
        text: "录音功能权限"
    },
    writePhotosAlbum: {
        desc: "保存到相册",
        text: "保存到相册权限"
    }
}, n = wx.openSetting, o = function(e) {
    return /fail[\s:]auth[\s:](denied|deny)/.test(e) || /authorize[\s:]fail/.test(e);
}, u = function(e, t, r) {
    n ? c(e, function() {
        a(e, t, r);
    }, r) : i(e);
}, c = function(e, t, r) {
    wx.showModal({
        title: "小程序需要你的允许才能正常使用",
        content: "请点击“去设置”并勾选“" + s[e].desc + "”，然后确定即可正常使用",
        confirmText: "去设置",
        success: function(e) {
            e.confirm ? t && t() : r && r();
        }
    });
}, i = function(e) {
    wx.showModal({
        title: "刚才的微信授权你未点击“允许”",
        content: "小程序正常运行需要获得" + s[e].text + "。请在发现-小程序，删除" + r.default.appName + "，再次打开" + r.default.appName + "，会重新提示微信授信，点“允许”，即可正常使用" + r.default.appName + "..."
    });
}, a = function(e, t, r) {
    n({
        success: function(s) {
            s.authSetting && s.authSetting["scope." + e] ? t && t() : r && r();
        }
    });
};

exports.default = {
    userInfo: function(e, r, s) {
        o(e.errMsg) ? u("userInfo", r, s) : t.default.qAlert(e.errMsg, "获取用户信息失败");
    },
    userLocation: function(e, r, s) {
        o(e.errMsg) ? u("userLocation", r, s) : /cancel/.test(e.errMsg) || t.default.qAlert(e.errMsg, "获取地理位置失败");
    },
    address: function(e, r, s) {
        o(e.errMsg) ? u("address", r, s) : /cancel/.test(e.errMsg) || t.default.qAlert(e.errMsg, "获取通讯地址失败");
    },
    record: function(e, r, s) {
        /short/.test(e.errMsg) ? wx.showToast({
            title: "录音时间太短",
            image: "/images/warning.png"
        }) : o(e.errMsg) ? u("record", r, s) : t.default.qAlert(e.errMsg, "获取录音失败");
    },
    writePhotosAlbum: function(e, r, s) {
        o(e.errMsg) ? u("writePhotosAlbum", r, s) : /cancel/.test(e.errMsg) || (s ? s() : t.default.qAlert(e.errMsg, "保存失败"));
    }
};